#include <iostream>
using namespace std;
#include <stdlib.h>
int A[5] = {1,5,2,10,3};
int t1 = 0, t2 = 0;
int comp(const void* n,const void* m) {
	return *(int*)m - *(int*)n;
}

int main() {
	// sort
	qsort(A, 5, sizeof(int), comp);
	for(int i = 0; i < 5; i++) {
		cout << A[i] << "\t";
	}
	cout << endl;
	// let everyone value distribute to min of sum of T
	for(int i = 0; i < 5; i++) {
		if ((t1+A[i]) > (t2+A[i])){
			t2 += A[i];
		} else{
			t1 += A[i];	
		}
	}
	
	if (t1 > t2)
		cout << "Those machine having spent " << t1 << " 's";	
	else 
		cout << "Those machine having spent " << t2 << " 's";
	return 0;
}

